﻿using UnityEngine;
using System.Collections;

namespace FrameWork
{
    /// <summary>
    /// 单例统一框架  通用的对象(抽象)
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class Singleton<T> where T:class,new()
    {

        private static T _intance = null;

        public static T Intance
        {
            get
            {
                if (null == _intance)
                {
                    _intance = new T();//调用构造函数
                }
                return _intance;
            }
        }
        /// <summary>
        /// 类构造函数
        /// </summary>
        protected Singleton()
        {
            //调用两次时抛异常
            if (null != _intance)
            {
                throw new SingleException("this" + (typeof(T)).ToString() + "Singleton Instance is not null!!");
            }
            Init();
        }
        public virtual void Init()
        {
        
        }
    }
}

